<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>超市账单管理系统</title>
    <link rel="stylesheet" href="/statics/css/public.css"/>
    <link rel="stylesheet" href="/statics/css/style.css"/>
    <script type="text/javascript" src="/statics/js/jquery.js"></script>
    <script type="text/javascript">
        $(function () {
            //获取所有供应商信息
            $.get("/sys/provider/queryAll",function (result) {
                $("select[name='providerId']").append("<option value='-1'>--请选择--</option>");
                $.each(result,function (index,d) {
                   $("select[name='providerId']").append("<option value='"+d.id+"'>"+d.proName+"</option>");
                });
            });


            //保存信息
            $("#saveButton").click(function () {
               //获取表单数据
                var data=$("form").serialize();
                $.post("/sys/bill/save",data,function (result) {
                    if(result=='success'){
                        alert("添加订单信息成功");
                        location.href = "/sys/bill/toList";
                    }else{
                        alert("添加失败请稍后再试");
                    }

                })
            });
        })
    </script>
</head>
<body>
<section class="publicMian ">
    <div class="right">
        <div class="location">
            <strong>你现在所在的位置是:</strong>
            <span>账单管理页面 >> 订单添加页面</span>
        </div>
        <div class="providerAdd">
            <form>
                <!--div的class 为error是验证错误，ok是验证成功-->
                <div class="">
                    <label for="billCode">订单编码：</label>
                    <input type="text" name="billCode" id="billCode" required/>
                    <span>*请输入订单编码</span>
                </div>
                <div>
                    <label for="productName">商品名称：</label>
                    <input type="text" name="productName" id="productName" required/>
                    <span >*请输入商品名称</span>
                </div>
                <div>
                    <label for="productUnit">商品单位：</label>
                    <input type="text" name="productUnit" id="productUnit" required/>
                    <span>*请输入商品单位</span>

                </div>
                <div>
                    <label for="productCount">商品数量：</label>
                    <input type="text" name="productCount" id="productCount" required/>
                    <span>*请输入大于0的正自然数，小数点后保留2位</span>
                </div>
                <div>
                    <label for="totalPrice">总金额：</label>
                    <input type="text" name="totalPrice" id="totalPrice" required/>
                    <span>*请输入大于0的正自然数，小数点后保留2位</span>
                </div>
                <div>
                    <label >供应商：</label>
                    <select name="providerId" >
                    </select>
                    <span>*请选择供应商</span>
                </div>
                <div>
                    <label >是否付款：</label>
                   <select name="isPayment">
                       <option value="-1">--请选择--</option>
                       <option value="1">已支付</option>
                       <option value="2">未支付</option>
                   </select>
                </div>
                <div class="providerAddBtn">
                    <input type="button" value="保存" id="saveButton"/>
                    <input type="button" value="返回" onclick="history.back(-1)"/>
                </div>
            </form>
        </div>

    </div>
</section>
</body>
</html>
